import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  /*!!! 路由重定向 !!!*/
  {
    path: '/',
    redirect:'/login'
  },
  {
    path: '/index',
    name: 'index',
    component: () => import('@/Index'),
    children:[
      {
        path: '/login',
        name: 'login',
        component: () => import('@/views/login'),
      },
      {
        path: '/test',
        name: 'test',
        component: () => import('@/views/test'),
      },
      {
        path: '/search',
        name: 'search',
        component: () => import('@/views/search'),
      },
      {
        path: '/feedback',
        name: 'feedback',
        component: () => import('@/views/feedback'),
      },
      {
        path: '/test_',
        name: 'test_',
        component: () => import('@/views/test_'),
      },
    ]
  },
]

const router = new VueRouter({
  mode: 'history',
  routes
})

//Home跳转Home报错
const VueRouterPush=VueRouter.prototype.push
VueRouter.prototype.push=function push (to){
  return VueRouterPush.call(this,to).catch(err=>err)
}

export default router
